/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
// -*- coding:iso-8859-15 mode: c++ -*-
/** 
 * \file
 * \brief MaCI_Image Player for logged data
 * \author Matthieu Myrsky <matthieu.myrsky@tkk.fi>
 *
 * $Id: ImageFilePlayer.hpp,v 1.7 2009-11-13 15:11:18 morsko Exp $
 *
 */
#ifndef _IMAGEFILEPLAYER_HPP_
#define _IMAGEFILEPLAYER_HPP_
#include "PNGDecoder.hpp"
#include <string>
#include <map>
#include <vector>
#include "PlayerModule.hpp"
#include "owndebug.h"
#include "ownutils.h"
#include "gimutils.h"
#include "ImageServer.hpp"
#include "ImageTypes.hpp"
#include "ImageContainer.hpp"
#include "JPEGDecoder.hpp"


class ImageFilePlayer: public PlayerModule
{
public:


  ImageFilePlayer(MaCI::Image::CImageServer *aImageServer,
                      std::string aFilename);

  virtual ~ImageFilePlayer();


  
  bool GetTimes(std::list<gim::time> *aTimes);

 
  bool OnTime(gim::time aTime);


  std::string GetName(void);

  void GetTimeLimits(gim::time &aBegin,gim::time &aEnd);
private:
  bool ReadData();
  MaCI::Image::CImageServer *iImageServer;
  // Time is the key and second is a vector size of images at this time
  // The vector has many formats if there was multiple images in the same
  // imageData packet
  std::map<gim::time,std::vector<unsigned int> > iData;
  // Time is the key and second is a vector of image types at this time
  // The vector has many formats(can be the same) if there was multiple images
  // in the same imageData packet
    std::map<gim::time,std::vector<MaCI::Image::TImageInfo> > iImageInfos;
  std::list<gim::time> iTimes;
  gim::time iBegin;
  gim::time iEnd;
  char iDirectory[512];
  FILE *iFile;
  std::string iName;
  MaCI::Image::EImageDataType iImageFormat;
  unsigned int iImageCount;
  //*****************************************************************************
  ImageFilePlayer(const ImageFilePlayer&)
    :PlayerModule(),
     iImageServer(NULL),
     iData(),
     iImageInfos(),
     iTimes(),
     iBegin(),
     iEnd(),
     iDirectory(),
     iFile(NULL),
     iName(""),
     iImageFormat(MaCI::Image::KImageDataUnknown),
     iImageCount(0){}
  ImageFilePlayer &operator=(const ImageFilePlayer&) { return *this; }
  //*****************************************************************************
};

#endif
